package com.team.employment.web.admin.controller.company;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.team.employment.common.result.Result;
import com.team.employment.model.entity.CompanyInfo;
import com.team.employment.model.enums.CompanyStatus;
import com.team.employment.web.admin.custom.check.IdIsEmptyCheck;
import com.team.employment.web.admin.dto.CompanyQueryDto;
import com.team.employment.web.admin.service.CompanyInfoService;
import com.team.employment.web.admin.vo.CompanyDetailVo;
import com.team.employment.web.admin.vo.CompanyStatutoryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "企业信息管理")
@RestController
@RequestMapping("/admin/companyInfo")
public class CompanyInfoController {

    @Autowired
    private CompanyInfoService companyInfoService;

    @Autowired
    private IdIsEmptyCheck idIsEmptyCheck;

    @Operation(summary = "分页查询所有企业信息")
    @GetMapping("pageInfo")
    public Result<IPage<CompanyStatutoryVo>> pageInfo(@RequestParam long current, @RequestParam long size){
        IPage<CompanyStatutoryVo> page = new Page<>(current,size);
        IPage<CompanyStatutoryVo> list  =companyInfoService.pageInfo(page);
        return Result.ok(list);
    }

    @Operation(summary = "根据不同条件模糊分页查询企业")
    @PostMapping("pageQueryInfo")
    public Result<IPage<CompanyStatutoryVo>> pageQueryInfo(@RequestParam long current, @RequestParam long size, @RequestBody CompanyQueryDto companyQueryDto){
        Page<CompanyStatutoryVo> page = new Page<>(current, size);
        IPage<CompanyStatutoryVo> list = companyInfoService.pageQueryInfo(page,companyQueryDto);
        return Result.ok(list);
    }

    @Operation(summary = "根据company_id查看单个企业的详细信息")
    @GetMapping("getInfoById/{id}")
    public Result<CompanyDetailVo> getInfoById(@PathVariable Long id){
        CompanyDetailVo vo = companyInfoService.getInfoById(id);
        return Result.ok(vo);
    }

    @Operation(summary = "根据company_id删除企业信息")
    @DeleteMapping("removeInfoById/{id}")
    public Result removeInfoById(@PathVariable Long id){
        idIsEmptyCheck.idIsEmpty(companyInfoService,id);
        companyInfoService.removeInfoById(id);
        return Result.ok();
    }


}
